package org.example.scenicspot.controller;

import org.example.scenicspot.domain.EmergencyRescueVehicle;
import org.example.scenicspot.domain.RealtimeInfo;
import org.example.scenicspot.service.realtimeInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/")

public class realtimeInfoController {
    @Autowired
    realtimeInfoService realtimeinfoService;
    @GetMapping("/realtimeInfo")
    public List<RealtimeInfo> showrealtimeInfo(){
        return realtimeinfoService.showrealtimeInfo();
    }

    @GetMapping ("/searchrealtimeInfo")
    public List<RealtimeInfo> searchscenicSpot(String keyword){
        System.out.println(keyword);
        return realtimeinfoService.searchrealtimeInfo(keyword);
    }

    @GetMapping ("/searchrealtimeInfoByID")
    public RealtimeInfo searchrealtimeInfoByID(int id){
        return realtimeinfoService.selectByID(id);
    }

    @PostMapping("/insertrealtimeInfo")
    public void insertrealtimeInfo(@RequestBody RealtimeInfo realtimeInfo){
        realtimeinfoService.insertRealtimeInfo(realtimeInfo);
    }

    @GetMapping("/deleterealtimeInfo")
    public void deleterealtimeInfo(int id){
        realtimeinfoService.deleteRealtimeInfo(id);
    }

    @GetMapping("/updaterealtimeInfo")
    public void updaterealtimeInfo(int id,String status){
        realtimeinfoService.update(id,status);
    }
}
